package org.example.springboot.controller;

import org.example.springboot.model.InBound;
import org.example.springboot.model.Returns;
import org.example.springboot.service.InBoundService;
import org.example.springboot.service.ReturnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
public class ReturnController {
    @Autowired
    private ReturnService returnService;

    @PostMapping("/insertReturn")
    public String insertReturn(@RequestBody Returns returns){
        return returnService.insertReturn(returns.getProductName(),returns.getModelNumber(),returns.getSupplierName(),returns.getQuantity(),returns.getTotalAmount(),returns.getReturnType(),returns.getInOrderId(),returns.getOutOrderId());
    }

    @GetMapping("/getAllReturns")
    public List<Returns> getAllReturns(){
        return returnService.getAllReturns();
    }

    @GetMapping("/findReturnByKeyword/{keyword}")
    public List<Returns> findReturnByKeyword(@PathVariable String keyword){
        return returnService.findReturnByKeyword(keyword);
    }

    @GetMapping("/getReturnById/{id}")
    public Returns getReturnById(@PathVariable int id){
        return returnService.getReturnById(id);
    }

    @DeleteMapping("/deleteReturnById/{id}")
    public void deleteReturnById(@PathVariable int id){
        returnService.deleteReturnById(id);
    }
}
